package oo.Day04.nigthText3max;

import java.util.Scanner;

public class CustomerView {

    public CustomerList customers = new CustomerList(10);

    public void enterMainMenu(){
        System.out.println("-----------------客户信息管理软件-----------------");
        System.out.println();
        System.out.println("\t            1 添加客户");
        System.out.println("\t            2 修改客户");
        System.out.println("\t            3 删除客户");
        System.out.println("\t            4 客户列表");
        System.out.println("\t            5 退   出");
        System.out.println();
        System.out.print("\t            请选择(1-5):");

        Scanner sc = new Scanner(System.in);
        Customer cc1 = new Customer();
        boolean flag = true;
        while (flag){
            flag = false;
            int i = sc.nextInt();
            switch (i){
                case 1:
                    CustomerView cc = new CustomerView();
                    cc.addNewCustomer();
//                    System.out.println("-----------------添加客户-----------------");
//                    System.out.println("姓名:");
//                    String s2 = sc.next();
//                    cc1.setName(s2);
//                    System.out.println("-----------------添加完成-----------------");

                    break;
                case 2:

//                    System.out.println("-----------------修改客户-----------------");
//                    System.out.println("-----------------修改完成-----------------");
                    break;
                case 3:
                    CustomerView cc2 = new CustomerView();
                    cc2.deleteCustomer();
//                    System.out.println("-----------------删除客户-----------------");
//                    System.out.println("-----------------删除完成-----------------");
                    break;
                case 4:
                    System.out.println("-----------------客户列表-----------------");
                    System.out.println("----------------客户列表完成---------------");
                    break;
                case 5:
                    flag=true;
                    System.out.println();
                    System.out.print("确认是否退出(Y/N):");
                    String s1 = sc.next();
                    if (s1.equals("Y")) {
                        System.out.println("感谢使用此系统!");
                        flag=false;
                        break;
                    } else if (s1.equals("N")) {
                        System.out.print("请选择(1-5):");
                        break;
                    }
                default:
                    flag=true;
                    System.out.println("输入不合法，请输入1~5:");
                    break;
            }

        }
    }




    private void addNewCustomer(){
        Scanner sc = new Scanner(System.in);
        Customer cc1 = new Customer();
        System.out.println("-----------------添加客户-----------------");
        System.out.print("姓名:");
        String s2 = sc.next();
        cc1.setName(s2);
        System.out.print("性别:");
        char s3 = sc.next().charAt(0);
        cc1.setGender(s3);
        System.out.print("年龄:");
        int s4 = sc.nextInt();
        cc1.setAge(s4);
        System.out.print("电话:");
        String s5 = sc.next();
        cc1.setName(s5);
        System.out.print("邮箱:");
        String s6 = sc.next();
        cc1.setName(s6);
        System.out.println("-----------------添加完成-----------------");

    }

    private void modifyCustomer(){

    }

    private void deleteCustomer(){
        Scanner sc = new Scanner(System.in);
        Customer cc1 = new Customer();
        System.out.println("-----------------删除客户-----------------");
        System.out.print("请选择待删除客户编号(-1退出):");
        int i1 = sc.nextInt();
        if (i1==-1){
            System.out.println("-----------------您已退出-----------------");
            return;
        }
        System.out.print("确认是否删除(Y/N):");
        String s1 = sc.next();
        if (s1.equals("Y")){
            System.out.println("-----------------删除完成-----------------");
        }else if(s1.equals("N")){
            System.out.println("-----------------取消删除-----------------");
        }

    }

    private void listAllCustomer(){

    }

    public static void main(String[] args) {

        CustomerView cc = new CustomerView();
        cc.enterMainMenu();
    }
//        Customer c = new Customer();
//        c.setName("张三");
//        c.setGender('男');
//        c.setAge(30);
//        c.setPhone("010-52776976");
//        c.setEmail("zhang@abc.com");
//        System.out.println(c.toString());

}
